package com.gm.wholesale.module.report.view;

import android.graphics.Paint;

import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;

public class BarChartUtil {
    public static void initBarChart(BarChart barChart){
        barChart.setScaleEnabled(false);

        //得到Description对象
        Description description = barChart.getDescription();
        description.setEnabled(false);
        description.setTextAlign(Paint.Align.LEFT);
        //设置偏移量
        // 获取 x 轴
        XAxis xAxis = barChart.getXAxis();
        xAxis.setDrawGridLines(false);
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        //设置最大值
        xAxis.setLabelCount(31);
        //设置文字旋转的角度
        xAxis.setLabelRotationAngle(120);

        xAxis.setAxisMinimum(0f);


        // 获取 左边 y 轴
        YAxis LeftAxis = barChart.getAxisLeft();
      // LeftAxis.setDrawGridLines(false);
        LeftAxis.setAxisMinimum(0f);


        // 获取 右边 y 轴
        YAxis yAxis = barChart.getAxisRight();
        yAxis.setEnabled(false);
    }
}
